package com.sz.jinzheng.until;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description: JwtUntil
 * @author: Sheep
 * @date: 2021年07月07日 14:57
 */
@Slf4j
@Component
public class JwtUntil {
    /**
     * 设置token过期时间为1个小时
     */
    private final static String ID = "yang";
    private final static long TTL = 3600000;


    /**
     * 解析token
     *
     * @param token
     * @return
     */
    public Claims parseToken(String token) {
        Claims claims = Jwts.parser().setSigningKey(ID).parseClaimsJws(token).getBody();
        log.debug("id = " + claims.getId());
        log.debug("getSubject = " + claims.getSubject());
        return claims;
    }
}
